﻿@using Webdiyer.WebControls.Mvc
@model PagedList<EAM.Model.AssetManager>
@{
    ViewBag.Title = "Index";

    var brandInfoDict = (Dictionary<int, string>)ViewData["brandInfoDict"];
}
@if (false)
{
    <script src="../../Scripts/jquery-1.5.1-vsdoc.js" type="text/javascript"></script>
}
<div style="padding: 5px 10px;">
    <a href="@Url.Action("edit", "Manager", new { cId = -1 })" class="btn_green">新建资产</a>
</div>

<div style="padding: 0px 10px;">
    <table class="tb" width="98%" style="text-align: center;">
        <tr>
            <th style="width: 20px;"></th>
            <th valign="top">序号</th>
            <th>名称</th>
            <th>标签</th>
            <th>状态</th>
            <th>供应商</th>
            <th>供应商联系人</th>
            <th>保修时间</th>
            <th>保管人</th>
            <th>使用人</th>
            <th>所在部门</th>
            <th>操作</th>
        </tr>
        @foreach (var m in Model)
        {
            <tr>
                <td>
                 <input type="checkbox" name="AssetID" value="@m.AssetID" />
                </td>
                <td>@m.AssetID</td>
                <td>@m.AssetName</td>
                <td>@m.AssetLabel</td>
                <td>@( ((Dictionary<int, string>)ViewData["statusDict"])[(m.AssetStatus ?? -1)]) </td>
                <td>@( ((Dictionary<int, string>)ViewData["supplyDict"])[(m.AssetSupply ?? -1)]) </td>
                <td>@brandInfoDict[(m.AssetSupply ?? -1)] </td>
                <td>@m.AssetWarrantLastTime</td>
                <td>@( ((Dictionary<Guid, string>)ViewData["AssetCustodyMemberIDDict"])[(m.AssetCustodyMemberID ?? new Guid())])</td>
                <td>@( ((Dictionary<Guid, string>)ViewData["AssetCustodyMemberIDDict"])[(m.AssetUsedMemberID ?? new Guid())])</td>
                <td>@( ((Dictionary<int, string>)ViewData["AssetDepartIDDict"])[(m.AssetDepartID ?? -1)])</td>
                <td width="80">
                    <a href="@Url.Action("edit", "Manager", new { id = m.AssetID })">编辑</a>
                    <a style="display:none;" href="@Url.Action("del", "Manager", new { id = m.AssetID })" onclick="return confirm('确认删除吗？')">删除</a>
                </td>
            </tr>
        }
        <tr>
            <td>
                <input type="checkbox" /></td>
            <td colspan="11" style="text-align: left;">
                <input type="button" value="删除" class="btn_red" onclick="deleteChooseManager()"  style="display:none;"/>
                <input type="button" value="打印" class="btn_red" onclick="printChooseManager()"  />
                 <div style="float: right;">
                    @Html.Pager(Model)
                </div>
            </td>
        </tr>
    </table>
</div>

<script type="text/javascript">

    function deleteChooseManager() {
        if (!confirm('确定删除吗？')) return;
         
        if ($("input[name='AssetID']:checked").length == 0) return;

        var arr = [];
        $("input[name='AssetID']:checked").each(function () {
            arr.push($(this).val());
        });
        

        $.post("/Manager/DeleteChoose", { ids: arr.join(',') }, function () {
            window.location = window.location;
        });
    }

    function printChooseManager() {
        if (!confirm('确定打印吗？')) return;
        if ($("input[name='AssetID']:checked").length == 0) return;

        var arr = [];
        $("input[name='AssetID']:checked").each(function () {
            arr.push($(this).val());
        });
        

        $.post("/Print/index", { ids: arr.join(',') }, function () {
            window.location = window.location;
        });

    }
</script>